package com.secondGroup.controller;


import com.secondGroup.entity.User;
import com.secondGroup.entity.VirtualBankCard;
import com.secondGroup.mapper.BankCardMapper;
import com.secondGroup.service.BankCardService;
import com.secondGroup.service.VirtualBankCardService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ws
 * @since 2022-05-05
 */
@Controller
public class BankCardController {
    @Resource
    VirtualBankCardService virtualBankCardService;
    @Resource
    BankCardMapper bankCardMapper;

    @RequestMapping("/tiecard")
    public String disp(HttpSession session , Model model){
        //获取去用户绑定的所有银行卡
        User user = (User) session.getAttribute("userInfo");
        List<VirtualBankCard> bankCardByAccount = bankCardMapper.getBankCardByAccount(user.getAccount());
        model.addAttribute("banks",bankCardByAccount);
        return "tieCard";
    }
    /**
     *绑卡
     * @Author ybk
     */
    @RequestMapping("/bundling")
    public String tieCard(String cid, Model model){

         VirtualBankCard virtualBankCard  = virtualBankCardService.selectinfo(cid);
        if(virtualBankCard == null){
            model.addAttribute("message","银行卡号不存在");
            return "fail";
        }else {
            return "verificationCard";
        }

    }
}
